# 找某一天是某一年第几天

def isLeapYear(y):
    return y % 400 == 0 or (y % 4 == 0 and y % 100 != 0)


DofM = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30]
res = 0
year = int(input("请输入年份："))
month = int(input("请输入月份："))
day = int(input("请输入日期："))
if isLeapYear(year):
    DofM[2] += 1

for i in range(month):
    res += DofM[i]

print(res + day)
